n = int(input())
list = []
hole = 0
for i in range(1,1001):
    hole += i
    if hole > n:
        if hole % n == 0:
            hole = n
        else:
            hole %= n
    list.append(hole)
judge = False
for j in range(1,n + 1):
    if j not in list:
        print(j)
        judge = True
if judge == False:
    print(0)
    '''dewa'''